package tutorial.main.control;

import java.util.Hashtable;

import android.os.Bundle;

public class OperationManager {

	public static final int STATUS_DONE = 0;
	public static final int STATUS_ERROR = 1;
	public static final int STATUS_IN_PROGRESS = 2;
	public static final int NO_STATUS = 3;	

	public static final int OPERATION_CONNECTIVITY_UPDATED = 1;

	private Hashtable<Integer, OperationListener> _listeneres;

	private static OperationManager instance;

	public static OperationManager getInstance() {
		if (instance == null) {
			instance = new OperationManager();
		}
		return instance;
	}

	private OperationManager() {
		_listeneres = new Hashtable<Integer, OperationListener>();
	}

	public void notify(int operation, int status, Bundle data) {
		OperationListener listener = _listeneres.get(operation);
		if (listener != null) {
			listener.onOperationStatusUpdated(operation, status, data);
		}
	}

	public void register(int operation, OperationListener listener) {
		_listeneres.put(operation, listener);
	}

	public void unregister(int operation) {
		_listeneres.remove(operation);
	}
}
